using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using SCS.Common.Models;
namespace SCS.DAL.Mapping
{
    public class GradeMap : EntityTypeConfiguration<Grade>
    {
        public GradeMap()
        {
            // Primary Key
            this.HasKey(t => t.gradeID);

            // Properties
            // Table & Column Mappings
            this.ToTable("Grade");
            this.Property(t => t.gradeID).HasColumnName("gradeID");
            this.Property(t => t.learnerID).HasColumnName("learnerID");
            this.Property(t => t.subjectID).HasColumnName("subjectID");
            this.Property(t => t.gradeTypeID).HasColumnName("gradeTypeID");
            this.Property(t => t.termID).HasColumnName("termID");
            this.Property(t => t.createDate).HasColumnName("createDate");
            this.Property(t => t.grade1).HasColumnName("grade");
            this.Property(t => t.isSent).HasColumnName("isSent");

            // Relationships
            this.HasRequired(t => t.GradeType)
                .WithMany(t => t.Grades)
                .HasForeignKey(d => d.gradeTypeID);
            this.HasRequired(t => t.Learner)
                .WithMany(t => t.Grades)
                .HasForeignKey(d => d.learnerID);
            this.HasRequired(t => t.Subject)
                .WithMany(t => t.Grades)
                .HasForeignKey(d => d.subjectID);
            this.HasRequired(t => t.Term)
                .WithMany(t => t.Grades)
                .HasForeignKey(d => d.termID);

        }
    }
}
